import Taro from '@tarojs/taro'
// eslint-disable-next-line import/prefer-default-export
let env = 'dev-d62e0'
if (false) {
    env = 'pro-sq9fk'
}

export const fetchRss = (data) => {

    Taro.showLoading()
    return new Promise((r1, r2) => {
        Taro.cloud.callFunction({
            name: 'fetchRss',
            data: { ...data },
            success: (r) => {
                r1(r.result);
            },
            complete: () => {
                Taro.hideLoading()
            },
            fail: r2
        });
    })
}
export const findRssDetail = (data) => {
    Taro.showLoading()
    return new Promise((r1, r2) => {
        Taro.cloud.callFunction({
            name: 'findRssDetail',
            data: { ...data },
            success: (r) => {
                r1(r.result);
            },
            complete: () => {
                Taro.hideLoading()
            },
            fail: r2
        });
    })
}
export const rssSubscribe = (data) => {
    //  Taro.showLoading()
    return new Promise((r1, r2) => {
        Taro.cloud.callFunction({
            name: 'rssSubscribe',
            data: { ...data },
            success: (r) => {
                r1(r.result);
            },
            complete: () => {
                //      Taro.hideLoading()
            },
            fail: r2
        });
    })
}
export const uploadSubscribe = (data) => {
    Taro.showLoading()
    return new Promise((r1, r2) => {
        Taro.cloud.callFunction({
            name: 'uploadSubscribe',
            data: { ...data },
            success: (r) => {
                r1(r.result);
            },
            complete: () => {
                Taro.hideLoading()
            },
            fail: r2
        });
    })
}
export const downloadSubscribe = (data) => {
    Taro.showLoading()
    return new Promise((r1, r2) => {
        Taro.cloud.callFunction({
            name: 'downloadSubscribe',
            data: { ...data },
            success: (r) => {
                r1(r.result);
            },
            complete: () => {
                Taro.hideLoading()
            },
            fail: r2
        });
    })
}
// export const querySubscribe = ():any => {
//     return new Promise((r1, r2) => {
//         let t = new Date
//         let version = `${t.getFullYear()}-${t.getMonth()}-${t.getDay()}-${t.getDay()}`;

//         wx.request({
//             url: 'https://cdn.fly178.com/wxapp/querySubscribe.json?_v='+version,
//             success:(r) => {
//                 r1(r.data);
//             },
//             fail:r2
//         })
//     })
// }